The semantics describe the meaning of a sentence. Because of the limited domain of the project, the semantics are rather restricted as well. The semantics is a form of \textit{compositional semantics}, which means that the semantics of a sentence is a combination of the semantics of its parts. The semantics simply maps each sentence to a list of functions, which are interpreted as instructions to the program. For example, the sentence "I want a banana" results in the expression "inc(obj(1, ingr(), banana))", which simply means that a banana should be included in the meal. 

To accomplish this mapping, semantic rules are associated with the grammar rules. By splitting different nouns or verbs into specialized wordcategories, it is possible to give these categories different semantical meaning. For instance, nouns that are ingredients place in the INGR-category, while other nouns are placed in other categories. 
\begin{center}
 \textbf{\begin{tabular}[c]{lrcl}
 	(1)& S &$<$-& NP VP ; \\
	(2)& NP &$<$-& PRO $<$nop(obj(1,ignore(),PRO))$>$ \\
	&&& $\mid$ ART NOUN $<\backslash$nt.nid obj(1,nt,nid)$>$ ; \\
	(3)& VP &$<$-& VERB NP $<\backslash$x.y x(y)$>$ ; \\
	(4)& VERB &$<$-& POSVERB $<$inc()$>$ ; \\
	(5)& NOUN &$<$-& INGR $<$inc(),INGR$>$ ; \\
\end{tabular}}
\end{center}
How these semantic rules are used can be seen in Figure \ref{fig:semantics}. The figure depicts a parse tree of the sentence "I want a banana". The first word "I" uses rule (2) above, which returns the semantic expression "nop(obj(1,ignore(),PRO))". This states that function nop (no operation) takes an object with quantity 1, type "ignore" and identifier PRO (which will be replaced by the word it represents, in this case "I"). So basically "I" is ignored.

\begin{figure}[!ht]
 \centering
 \includegraphics[scale=0.24]{ParseTreeWithSemantics.pdf}
 % ParseTreeWithSemantics.pdf: 1179666x1179668 pixel, 0dpi, infxinf cm, bb=
 \caption{A parse tree with semantics.}
 \label{fig:semantics}
\end{figure}

The next word "want" uses rule (4) and tells us that the semantics of the word is the function inc() which stands for include. The word "a" has no semantic interpretation by itself, but is used by later rules. The last word "banana" gives two semantic expressions, type ingredient and identifier INGR, which is a wordcategory for ingredients (replaced by the word "banana").

By the second part of rule (2), the article "a" and the noun "banana" is combined. The rule \textit{$\backslash$nt.nid obj(1,nt,nid)}, is somewhat inspired by lambda calculus. The parameters \textit{nt} and \textit{nid} takes semantic expressions from the children of the current node in the tree (left to right). In this case, the article gives no semantics so the parameters will take the two expressions from the noun and put them into the object, which becomes \textit{obj(1,ingr(),banana)}.

The VP in the tree uses rule (3), and the semantics of the verb and NP is combined. Parameter \textit{x} is replaced by the function \textit{inc()} and parameter \textit{y} is replaced by the ingredient object, resulting in \textit{inc(obj(1,ingr(),banana))}.

When the semantics has been found, the functions are executed, which in this case means that banana is added to the list of ingredients.

To handle some more advanced semantics, the syntax was augmented with a new type of operator on the parameters. For instance, the rule \textit{$<\backslash$a+.b+ and(a, b)$>$} defines an \textit{and} function which can take several objects (for example if both apple and banana are included in the same sentence). The + operator means that all object from the "current branch" of the tree is to be used (at least in this case, see next example). When the rule is used as in this example, there should be at least two child branches, the semantic expressions from first branch from the left get put in place of \textit{a} and the second branches expressions get put in \textit{b}.

Given a similar rule like $<\backslash$f.o+ f(o)$>$, where there are both "normal" parameters and + parameters, things are done a bit differently. The parameter \textit{f} takes the first expression it finds (if there were more than one "normal" parameter, they would pick expressions in order, regardless of branch). The \textit{o} is then replaced by all expression that have not been used from previous branches (if there are any) and all expressions from the second branch (since \textit{o} is the second parameter). This kind of rule could for example be used to include several objects.
